<!-- 包材类型管理 - 综合表单页面 -->
<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="SuperTablePage">
    </ex_super_table_page>
    <ex_super_dialog_form ref="formDialog" :title="dialogTitle" v-bind="dialog" @afterSubmitSuccess="submitSuccess" />
  </div>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';
let moduleName = "包材类型管理"

export default {
  title: moduleName,
  mixins: [superTablePageFunction],
  components: {},
  data() {
    return {

      option: {
        search: {
          model: [

            { label: "label_warehouse_area_code", key: "code", type: 'input',  },
            {
              label: "label_status", key: "status", type: 'select', enum: 'IsAvailableStatusEnum', 
            },
            {
              label: "label_start_time",
              key: "createDateStart",
              fold: true,
              type: 'date-picker',
              attrs: {  type: "datetime" },
            },
            {
              label: "label_end_time",
              key: "createDateEnd",
              fold: true,
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
            //所有元素均可添加可选attrs对象增加属性，详细属性列表由element-ui提供
          ],
        },
        action: [
          {
            label: '新增' + moduleName,auth:'wms_material_type_edit', attrs: { icon: "el-icon-plus" }, click: () => {
              this.dialogTitle = '新增' + moduleName
              this['$refs']['formDialog'].show(null, { setData: true })
            }
          },
        ],

        table: {
          url: "/wms-api/base/WmsBasePackMaterialTypeRpc/selectPage.json",
          attrs: {},
          model: [
            { key: 'warehouseCode', label: 'label_warehouse_code', },
            { key: 'code', label: '包材类型编码', },
            { key: 'name', label: '包材类型名称', },
            { key: 'nameEn', label: '包材类型英文名称', },
            { key: 'status', label: 'label_status', formatter: (r, c, v, i) => this.$enumShow(v, "IsAvailableStatusEnum"), width: 120, },
            { key: 'gmtCreate', label: 'label_create_time', 'min-width': 120, 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$dateFormat(v) },
            {
              type: 'operate', width: 160, operate: [
                {
                  label: 'label_edit',auth:'wms_material_type_edit', click: (row) => {
                    this.dialogTitle = '编辑' + moduleName
                    this['$refs']['formDialog'].show({ "id": row["id"] }, false)
                  }
                },
                {
                  label: 'label_delete',auth:'wms_material_type_delete', type: "confirm-button", url: '/wms-api/base/WmsBasePackMaterialTypeRpc/remove.json', message: '确定要删除该记录吗？',
                  buttonClass: "button_text_danger", confirmButtonType: 'danger',
                  params: (row) => { return { "id": row["id"] } }, done: ['reload', 'tip']
                },
              ],
            }
          ],

        }
        ,

      },

      dialogTitle: '',
      dialog: {
        submitUrl: '/wms-api/base/WmsBasePackMaterialTypeRpc/saveUpdate.json',
        detailUrl: '/wms-api/base/WmsBasePackMaterialTypeRpc/detail.json',
        form: {
          //弹窗表单设置，设置方式与搜索框对象一致。
          default: { status: "ENABLE" },
          model: [
            { header: "label_base_info", },

            // {
            // label: "所属仓库", key: "warehouseId", type: 'base_warehouse_select',  keyExtra: { code: 'warehouseCode', name: 'warehouseName' },
            // },
            { key: 'code', label: '包材类型编码', },
            { key: 'name', label: '包材类型名称', },
            { key: 'nameEn', label: '包材类型国际化名称', },
            { key: 'status', label: 'label_status', type: 'select', enum: 'IsAvailableStatusEnum' },
          ],
          rules: {
            // 'warehouseId': { required: true, message: '请输入仓库', trigger: 'blur' },
            'code': { required: true, message: '请输入包材类型编码', trigger: 'blur' },
            'name': { required: true, message: '请输入包材类型名称', trigger: 'blur' },
            'status': { required: true, message: '请输入状态', trigger: 'blur' },
          },
        }
      },
    };
  },
  methods: {
    submitSuccess() {
      this.reload()
      this.$refreshStoreCommonDataGroup('/wms-api/base/WmsBasePackMaterialTypeRpc/selectLabel.json')
    }
  }
};

</script>
<style></style>
